From ac094e893bf94d7d6d267abaedfa89bbb60e9ed6 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sun, 7 Sep 2014 11:48:35 -0700 Subject: [PATCH] Don't deadlock when a dep has no libs --- src/cargo/ops/cargo_rustc/mod.rs | 4 ++++ tests/test_cargo_compile.rs | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index f9cb09631..1ff4190a3 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -81,6 +81,10 @@ pub fn compile_targets<'a>(env: &str, targets: &[&'a Target], pkg: &'a Package, cx.is_relevant_target(*target) }).collect::>(); + if targets.len() == 0 { + return Err(human(format!("Package `{}` has no library targets", dep))) + } + try!(compile(targets.as_slice(), dep, &mut cx, &mut queue)); } diff --git a/tests/test_cargo_compile.rs b/tests/test_cargo_compile.rs index 9c754cc34..efaa330c8 100644 --- a/tests/test_cargo_compile.rs +++ b/tests/test_cargo_compile.rs @@ -1641,3 +1641,28 @@ test!(rebuild_preserves_out_dir { {compiling} foo v0.0.0 ({url}) ", compiling = COMPILING, url = foo.url()))); }) + +test!(dep_no_libs { + let foo = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.0" + authors = [] + + [dependencies.bar] + path = "bar" + "#) + .file("src/lib.rs", "pub fn bar() -> int { 1 }") + .file("bar/Cargo.toml", r#" + [package] + name = "bar" + version = "0.0.0" + authors = [] + "#) + .file("bar/src/main.rs", ""); + assert_that(foo.cargo_process("build"), + execs().with_status(101) + .with_stderr("\ +Package `bar v0.0.0 ([..])` has no library targets")); +}) -- 2.30.2